package com.itboye.ihomebank.myzhujia;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.base.MyApplcation;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.util.SPUtils;

/**
 * 居家维修
 * 
 */
public class ActivityHomeRepair extends BaseOtherActivity {
	TextView add_shap_title_tv;
	ImageView close_icon;
	WebView home_web;
	TextView home_ok;

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.close_icon:
			finish();
			break;
		case R.id.home_ok:
			Intent intent = new Intent(MyApplcation.ctx,
					ActivityJvJiaRepair.class);
			intent.putExtra("type", 1);
			intent.putExtra("title", getIntent().getStringExtra("title"));
			startActivity(intent);
			break;
		default:
			break;
		}
	}

	@Override
	protected int layout_id() {
		return R.layout.activity_home_repair;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	@SuppressLint("SetJavaScriptEnabled")
	@Override
	protected void onInit() {
		// TODO Auto-generated method stub
		add_shap_title_tv.setText(getIntent().getStringExtra("title"));

		// 设置WebView属性,能够执行Javascript脚本
		home_web.getSettings().setJavaScriptEnabled(true);
		home_web.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				view.loadUrl(url);
				return true;
			}
		});

		String url = "http://api.ihomebank.com/public/webview.php";
		String uid = SPUtils.get(this, null, SPContants.USER_ID, "") + "";
		String pass = SPUtils.get(this, null, SPContants.PASSWORD, "") + "";

		String url02 = url + "/repair?uid=" + uid + "&psw=" + pass
				+ "&status="+(getIntent().getStringExtra("title").equals("家电维修")?1:2);
		home_web.loadUrl(url02);
		// home_web.loadUrl("http://api.ihomebank.com/public/webview.php/repair/select?uid=128&psw=e56d09a4e36a3281d98176728bf24683&status=1");

	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}

}
